<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>ECSHOP 管理中心 - <?php echo ($meta_title); ?> </title>
    <meta name="robots" content="noindex, nofollow">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="/Public/css/general.css" rel="stylesheet" type="text/css"/>
    <link href="/Public/css/main.css" rel="stylesheet" type="text/css"/>
    <script src="/Public/js/jquery-1.11.3.js"></script>

    
    <link rel="stylesheet" type="text/css" href="/Public/ext/zTree/css/zTreeStyle/zTreeStyle.css" />
    <style>
        ul.ztree {
            margin-top: 10px;
            border: 1px solid #617775;
            background: #f0f6e4;
            width: 220px;
            overflow-y: scroll;
            overflow-x: auto;
        }
    </style>

    
    <script src="/Public/ext/zTree/js/jquery.ztree.core.js"></script>
    <script>
        $(function(){
            var setting = {
                data: {
                    simpleData: {
                        enable: true,
                        pIdKey:'parent_id',
                    }
                },
                callback:{
                    onClick:function(event,treeId,treeNode,clickFlag){
                        $('#parent_name').val(treeNode.name);
                        $('#parent_id').val(treeNode.id);
                    }
                }
            };

            $(document).ready(function(){
                var zNodes = <?php echo ($jsondata); ?>;
               var ztree_obj = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
                ztree_obj.expandAll(true);
                //编辑显示父节点
              var parent_node = ztree_obj.getNodeByParam("id", <?php echo ((isset($row['parent_id']) && ($row['parent_id'] !== ""))?($row['parent_id']):0); ?>);
                  console.debug(parent_node);
                  //判断是否有父节点,默认选中该节点
//                      //把名字和id填到对应的input
                       ztree_obj.selectNode(parent_node);
                       $('#parent_name').val(parent_node.name);
                        $('#parent_id').val(parent_node.id);
//         
            });

        });
    </script>
    <block name="main">
        <h1>
            <span class="action-span1"><a href="<?php echo U('index');?>">权限管理</a></span>
            <span id="search_id" class="action-span1"> - <?php echo ($meta_title); ?> </span>
            <div style="clear:both"></div>
        </h1>
        <div class="main-div">
            <form method="post" action="<?php echo U();?>"enctype="multipart/form-data" >
                <table cellspacing="1" cellpadding="3" width="100%">
                    <tr>
                        <td class="label">权限名称</td>
                        <td>
                            <input type="text" id="namex" name="name" maxlength="60" value="<?php echo ($row["name"]); ?>" />
                            <span class="require-field">*</span>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">路径</td>
                        <td>
                            <input type="text" name="path" maxlength="60" value="<?php echo ($row["path"]); ?>" placeholder="如果是目录型的可以不填"/>
                        </td>
                    </tr>
                    <tr>
                         <td class="label">父级分类</td>
                        <td>
                            <input type="hidden" name="parent_id" id="parent_id">
                            <input type="text" disabled="disabled" id="parent_name" value="请选择"/>
                            <ul id="treeDemo" class="ztree"></ul>
                        </td>
                    </tr>   
                    <tr>
                        <td class="label">权限描述</td>
                        <td>
                            <textarea  name="intro" cols="60" rows="4"  ><?php echo ($row["intro"]); ?></textarea>
                        </td>
                    </tr>   
                    <tr>
                        <td class="label">排序</td>
                        <td>
                            <input type="text" name="sort" maxlength="40" size="15" value="<?php echo ($row["sort"]); ?>" />
                        </td>
                    </tr>
                    <tr>
                        <td class="label">是否显示</td>
                        <td>
                            <input type="radio" name="status" value="1" checked="checked" /> 是
                            <input type="radio" name="status" value="0"  /> 否
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" align="center"><br />
                            <input type="hidden" value="<?php echo ($row["id"]); ?>" name="id">
                            <input type="submit" class="button" value=" 确定 " />
                            <input type="reset" class="button" value=" 重置 " />
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    
</head>
<body>

<div id="footer">
    共执行 <?php echo N('db_query');?> 个查询，用时 <?php echo G('loadTime','initTime');?> 秒，Gzip 已禁用，内存占用 <?php echo number_format((memory_get_usage() - $GLOBALS['_startUseMems'])/1024);?> KB<br/>
    版权所有 &copy; 重庆京西商城，并保留所有权利。
</div>
</body>
</html>